React Js / UI / Convert html template to react
Html Template
-
1. Step
Step 1: sample html
Simple HTML Page My Website
Welcome
This is a static HTML page.
Step 2: Create a React App (using Vite for speed)
npm create vite@latest my-react-app -- --template react cd my-react-app npm install npm run dev Step 3: Clean the Project
1. Delete everything inside src/App.jsx
2. Delete src/assets/* if not needed
3. Clean up src/App.css or replace with your CSS
Step 4: Convert HTML to JSX
Open src/App.jsx and paste:
function App() { return ( ); } export default App;My Website
Welcome
This is a static HTML page.
Make sure you:
1. Replace class with className
2. Close tags like
, , etc.
3. Use one root element (usually a
or <> ... >)Step 5: Add CSS
Move your styles into src/index.css (or use App.css).
/* src/index.css */ body { margin: 0; font-family: Arial; } header { background: #333; color: white; padding: 1rem; } nav a { margin: 0 10px; } Make sure it's imported in main.jsx:
import React from 'react'; import ReactDOM from 'react-dom/client'; import App from './App'; import './index.css'; ReactDOM.createRoot(document.getElementById('root')).render( );Step 6: Split Into Components
Create a folder src/components/ and split your template:
Header.jsx
Header.jsx
Nav.jsx
Main.jsx
Footer.jsx
Use in App.jsx:const Header = () => ( ); export default Header;My Website
import Header from './components/Header'; import Nav from './components/Nav'; import Main from './components/Main'; import Footer from './components/Footer'; function App() { return ( <> > ); }
MANVIA BLOG